package nc.tf.rest2025;

import com.alibaba.fastjson.JSONObject;
import nc.bs.framework.common.NCLocator;
import nc.bs.framework.server.ISecurityTokenCallback;
import nc.tf.service2025.IRedSaleInvoiceSaveService;
import nc.tf.service2025.ISaleOrderSaveService;
import nc.vo.scmpub.api.rest.utils.RestUtils;
import nc.vo.scmpub.res.Module;
import org.json.JSONString;
import uap.ws.rest.resource.AbstractUAPRestResource;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("sorder/service")
public class SaleOrderRestResource extends AbstractUAPRestResource {

    @POST
    @Path("/revise")
    @Consumes({"application/json"})
    @Produces({"application/json"})
    public JSONString checkSave(JSONObject jsonDTO) throws Exception {
        dobeforeaction();
        ISaleOrderSaveService service = NCLocator.getInstance().lookup(ISaleOrderSaveService.class);
        JSONObject result = service.synBillSave_RequiresNew(jsonDTO);
        return RestUtils.toJSONString(result);
    }

    public void dobeforeaction() {
        ISecurityTokenCallback sc = (ISecurityTokenCallback) NCLocator.getInstance().lookup(ISecurityTokenCallback.class);
        sc.token("NCSystem".getBytes(), "pfxx".getBytes());
    }

    @Override
    public String getModule() {
        return Module.SO.getName();
    }

}
